package org.ffmmx.ybb.model;

import org.springframework.data.domain.Page;

public class PageResult<T> extends Result<T> {
    Long total;
    Integer page;
    Integer limit;
    Integer totalPages;

    public PageResult(Page<T> page) {
        super();
        total = page.getTotalElements();
        totalPages = page.getTotalPages();
        limit = page.getSize();
        this.page = page.getNumber();

        this.code = 0;
        this.data = page.getContent();
    }

    public Integer getTotalPages() {
        return totalPages;
    }

    public void setTotalPages(Integer totalPages) {
        this.totalPages = totalPages;
    }

    public Long getTotal() {
        return total;
    }

    public void setTotal(Long total) {
        this.total = total;
    }

    public Integer getPage() {
        return page;
    }

    public void setPage(Integer page) {
        this.page = page;
    }

    public Integer getLimit() {
        return limit;
    }

    public void setLimit(Integer limit) {
        this.limit = limit;
    }
}
